package ResponsibilityChain

import "strconv"

type Handler interface {
	Handler(id int) string
}
type handler struct {
	name string
	next Handler
	id   int
}

func NewHandler(name string, next Handler, id int) *handler {
	return &handler{
		name: name,
		next: next,
		id:   id,
	}
}

func (h *handler) Handler(id int) string {
	if h.id == id {
		return h.name + " handled " + strconv.Itoa(id)
	}
	return h.next.Handler(id)
}
